<%@page import="javax.portlet.RenderRequest"%>
<%@page import="com.liferay.portal.kernel.servlet.SessionErrors"%>
<%@page import="com.liferay.portal.kernel.util.JavaConstants"%>
<%@page import="javax.portlet.PortletRequest"%>
<%@page import="com.liferay.portal.kernel.portlet.LiferayWindowState"%>
<%@page import="com.bkav.portal.portlet.product.ProductAdminPortlet"%>
<%@page import="javax.portlet.RenderResponse"%>
<%@page import="com.liferay.portal.util.PortalUtil"%>
<%@page
	import="com.bkav.portal.portlet.product.service.ProductLocalServiceUtil"%>
<%@page import="com.bkav.portal.portlet.product.model.Product"%>
<%@page import="java.util.List"%>
<%@page import="com.liferay.portal.kernel.util.ParamUtil"%>
<%@page
	import="com.liferay.portlet.documentlibrary.service.DLAppServiceUtil"%>
<%@page import="com.liferay.portal.kernel.servlet.SessionMessages"%>
<%@page import="com.liferay.portal.kernel.util.Validator"%>
<%@page import="com.liferay.portal.kernel.util.StringPool"%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://alloy.liferay.com/tld/aui" prefix="aui"%>
<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet"%>
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui"%>
<%@ taglib uri="http://liferay.com/tld/util" prefix="liferay-util"%>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<portlet:defineObjects />
<%
long productId = ParamUtil.getLong(request, "productId");
Product product = ProductLocalServiceUtil.getProduct(productId);
String productAdminPortletResource = "product_admin_WAR_productportlet";
%>
<c:choose>
<c:when test='<%=SessionMessages.contains(renderRequest, "Order-save-done")%>' >
	<aui:script>
       Liferay.Util.getOpener().refresh();
       Liferay.Util.getWindow().close();
    </aui:script>
</c:when>
<c:otherwise>

			<liferay-portlet:renderURL var="weblinkUpdateFormURL">
			<liferay-portlet:param name="jspPage"
				value="/html/product_admin/view.jsp" />
			</liferay-portlet:renderURL>
			<liferay-portlet:actionURL name="updateOrder" var="updateOrderActionURL"
				portletName="<%=productAdminPortletResource%>">
			<liferay-portlet:param name="productId"
				value="<%=String.valueOf(productId)%>" />
			<liferay-portlet:param name="redirectURL"
				value="<%=PortalUtil.getCurrentURL(request)%>" />
			</liferay-portlet:actionURL>
			<aui:form name="order" method="post" action="<%=updateOrderActionURL%>">
			<aui:input name="productName" value="<%=product.getProductName()%>"
				label="product" />
			<aui:input name="SL" label="Số lượng" />
			<aui:input name="email" labal="email" />
			<aui:button-row>
				<aui:button type="submit" value="save" />
				<aui:button value="cancel" />
			</aui:button-row>
			</aui:form>
			
			
			<aui:script>
			
			AUI().ready('aui-loading-mask', 'aui-io-request',function(A){
			
				var closeFormBtn = A.one('#<portlet:namespace />closeFormBtn');
				
				if(closeFormBtn){
					
					closeFormBtn.on('click',function(){
						Liferay.Util.getWindow().close();
					});
				}
			
						
				Liferay.provide(
					window,
					'<portlet:namespace />addVideoFolder',
					function() {
						
						var formContainer = A.one('#<portlet:namespace />fm');
						
						formContainer.plug(A.LoadingMask, { background: '#d2d2d2' });
						
						formContainer.loadingmask.toggle();
						
						A.io.request(
							document.<portlet:namespace />fm.action,
							{
								dataType: 'html',
								form: {
									id: document.<portlet:namespace />fm
								},
								after: {
									success: function() {
										Liferay.Util.getOpener().refresh();
										Liferay.Util.getWindow().close();
									}
								}
							}
						);
					}
				);
			});	
					
			</aui:script>

</c:otherwise>
</c:choose>